from pymysql import connect

# 获取mysql连接对象
conn = connect(
    host="localhost",
    port=3306,
    user="root",
    password="root",
    # autocommit=True # 自动提交
)
# 打印信息
# print(conn.get_server_info())

cursor = conn.cursor()  # 获取游标对象
# 选择数据库
conn.select_db("test")
# 执行sql
# cursor.execute("create table test_pymysql(id int)")
cursor.execute("select * from student")
# cursor.execute("insert into test_pymysql(id) values (1)")
# conn.commit()
res = cursor.fetchall()
for data in res:
    print(data)
print(type(res))
conn.close()
